<template>
  <div class="list-table">
    <div class="area-header">
      <span class="area-header-title">{{ $t('休假信息') }}</span>
    </div>
    <el-table v-loading="loading" :data="oaVacationList" border>
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('申请标题')" align="center" prop="actTitle" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <el-link type="primary" @click="updateHandle(scope.row)">{{ scope.row.actTitle }}</el-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('申请人')" align="center" prop="applicantName" show-overflow-tooltip width="110" />
      <el-table-column :label="$t('休假类型')" align="center" prop="" show-overflow-tooltip width="110">
        <template slot-scope="scope">
          <span
            v-for="(item,index) in scope.row.oaVacationDetails"
            :key="index"
          >{{ $t(item.type) }}{{ index === scope.row.oaVacationDetails.length - 1 ? '' : ',' }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('申请时间')" align="center" prop="applicationTime" show-overflow-tooltip width="110">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applicationTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('起始日期')" align="center" prop="startDate" show-overflow-tooltip width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startDate) }} / {{ parseTime(scope.row.endDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('申请休假天数')" align="center" prop="removeHoliday" show-overflow-tooltip width="100" />
      <el-table-column :label="$t('审批状态')" align="center" width="120">
        <template slot-scope="scope">
          <ProcessStatus :status="scope.row.actStatus" :act-id="scope.row.actId" />
        </template>
      </el-table-column>
      <el-table-column :label="$t('操作')" fixed="right" align="center" class-name="small-padding fixed-width" width="100">
        <template slot-scope="scope">
          <el-button
            v-hasPermi="['oa:vacation:view']"
            size="small"
            type="text"
            icon="el-icon-edit"
            @click="selectHandle(scope.row)"
          >{{ $t('选择') }}</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog
      :title="$t('休假详情')"
      :visible.sync="formOpen"
      custom-class="fixedDialog"
      width="70%"
      :close-on-click-modal="false"
      :lock-scroll="false"
      append-to-body
    >
      <oaVacationForm ref="oaVacationForm" />
    </el-dialog>
  </div>
</template>

<script>
import { listNotLeave } from '@/api/oa/vacation/vacation/oaVacation'
import oaVacationForm from '../vacation/vacation/oaVacationForm.vue'
export default {
  components: {
    oaVacationForm
  },
  props: {
    param: {
      type: Object,
      default: undefined,
      desc: '查询参数'
    }
  },
  data() {
      return {
        // 遮罩层
        loading: true,
        // 总条数
        total: 0,
        // 休假申请表格数据
        oaVacationList: [],
        // 弹出层标题
        title: '休假申请',
        // 是否显示弹出层
        formOpen: false,
        // 查询参数
        queryParams: {
          applicant: undefined,
          applicationTime: undefined,
          deptId: undefined,
          phone: undefined,
          startDate: undefined,
          endDate: undefined,
          vacationDay: undefined,
          removeHoliday: undefined,
          workUser: undefined,
          noticeUsers: undefined,
          pageNum: 1,
          pageSize: 10
        },
        // 日期范围
        dateRange: [],
        // 表单参数
        form: {},
        // 表单校验
        rules: {}
      }
  },
  created() {
  },
  methods: {
    /** 查询项目收款列表 */
    getList(id) {
      this.loading = true
      this.queryParams.id = id
      listNotLeave(this.queryParams).then(response => {
        this.oaVacationList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        applicant: undefined,
        applicationTime: undefined,
        deptId: undefined,
        phone: undefined,
        startDate: undefined,
        endDate: undefined,
        vacationDay: undefined,
        removeHoliday: undefined,
        workUser: undefined,
        noticeUsers: undefined,
        remark: undefined,
        createBy: undefined,
        createTime: undefined,
        updateBy: undefined,
        updateTime: undefined,
        delFlag: undefined
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    queryHandle() {
        this.queryParams.pageNum = 1
        this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.resetForm('queryForm')
      this.collectionTimes = []
      this.queryHandle()
    },
    /** 修改按钮操作 */
    updateHandle(row) {
      this.formOpen = true
      this.$nextTick(() => {
        // 调用form页面的 init 方法初始化数据
        this.$refs.oaVacationForm.init(row)
      })
    },
    /** 选择按钮操作 */
    selectHandle(row) {
      this.$parent.$parent.formOpen = false
      this.$parent.$parent.getOaVacationData(row)
    }
    /** 选择按钮操作 */
  }
}
</script>
